﻿using ParboiledSharp.parboiled.dataobjects;

namespace ParboiledSharp.parboiled.rules
{
    class PushMatch : Rule
    {
        private string _prefix = null;
        
        public PushMatch(string prefix) {
            _prefix = prefix;
        }

        public PushMatch()
        {
        }
        internal override bool Execute(Context context)
        {
            if (_prefix == null)
            {
                context.GetStack().Push(context.GetMatch());
            }
            else {
                context.GetStack().Push(_prefix+context.GetMatch());
            }
            
            return true;
        }
    }
}
